//
//  ViewController.m
//  DEMO
//
//  Created by J on 16/3/22.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *grayView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}



- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    CAAnimationGroup* group = [CAAnimationGroup animation];
    
    CABasicAnimation* scale = [CABasicAnimation animation];
    scale.keyPath = @"transform.scale";
    scale.toValue = @(0.5);

    
    CABasicAnimation* rotation = [CABasicAnimation animation];
    rotation.keyPath = @"transform.rotation";
    rotation.toValue = @(arc4random_uniform(M_PI));
    
    
    CABasicAnimation* position = [CABasicAnimation animation];
    position.keyPath = @"position";
    position.toValue = [NSValue valueWithCGPoint:CGPointMake(arc4random_uniform(200), arc4random_uniform(200))];

    group.animations = @[scale,rotation,position];//同时执行里面的很多动画对象
    
    [_grayView.layer addAnimation:group forKey:nil];
   
    
}



@end
